home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / xq-xsetup / files / setup.exe / {app} / plugins / XQ NoOpen Files.xpl < prev    next >
Text File  |  2002-03-14  |  6KB  |  204 lines

  1. "FILE"="Xteq Systems X-Setup Plugin 5.0"
  2. "TYPE"="8"
  3. "COUNT"="2"
  4. "UIPATH"="Appearance\Files&Folders\Files Open Warning"
  5. "NAME"="Edit File Open Warnings"
  6. "VERSION"="1.00"
  7. "LANGUAGE"="VBScript"
  8. "TEXT 1"="Change"
  9. "TEXT 2"="Delete"
  10. "OSVERSION"="000101"
  11. "DESCRIPTION 1"="Every known file type in Windows can be assigned a so called "Open Warning". If a "Open Warning" is set for a file and a user tries to open that file, it will receive a warning that this file should not be open. The warning message can either be the Windows default warning (This file is used by the operating system blah blah blah) or you can choose your own warning."
  12. "DESCRIPTION 2"="Just select the file in question and select "Change" to change the warning that should appear, or "Delete" to remove the warning. If you do not provide any text for the Open Warning, Windows will display a default warning."
  13. "DESCRIPTION 3"="Hint: If the file you want to change does not appear in this list, use the "Add File Open Warning" plug-in."
  14. "AUTHOR"="Xteq Systems"
  15. "CONTACTURL"="http://www.xteq.com"
  16. "COPYRIGHT"="Copyright ⌐ Xteq Systems - All Rights Reserved"
  17. "COMMENT 1"="Bloody complicated plug-in!!!"
  18.  
  19.  
  20. sP="HKLM\Software\Classes\"
  21.  
  22. dim iItems        'contains the total amount of the registry keys
  23. Dim aryItems()    'contains the name of the Registry paths (direct files starting with ".")
  24. Dim aryItemsLoc() 'contains the registry location  (\ShellNew or \ShellNew-)
  25. Dim aryDesc()     'contains the description of the items
  26.  
  27.  
  28. Sub Plugin_Initialize 
  29.  if RegPathExists(sP) then
  30.     Call ReadRegistry
  31.  else
  32.     Call Disable
  33.  end if
  34. End Sub
  35.  
  36.  
  37. Sub ReadRegistry
  38.     iItems=RegEnumPaths(sP) 
  39.  
  40.     dim aryTemp
  41.     ReDim aryTemp(iItems)
  42.     dim aryTemp2
  43.     ReDim aryTemp2(iItems)
  44.  
  45.     l=1
  46.     e=1
  47.  
  48.     sDebug=""
  49.  
  50.     'read all data from the path
  51.     For l=1 to iItems       
  52.         sItem=RegEnumElement(l)    
  53.  
  54.         if left(sItem,1)="." then
  55.            s=HasOpenWarning(sP, sP & sItem)
  56.  
  57.            If len(s)>0 then
  58.               sDebug=sDebug & sItem
  59.               aryTemp(e)=sItem
  60.               aryTemp2(e)=s
  61.               e=e+1
  62.            end if                
  63.         end if
  64.     next
  65.     'Call DebugMsg(sDebug)
  66.  
  67.  
  68.  
  69.     'okay, now count how many items we have left (that are not empty)...
  70.     iItems=0
  71.     for l=1 to e-1
  72.         If Len(aryTemp(l))>0 then
  73.            iItems=iItems+1
  74.         end if 
  75.     next 
  76.  
  77.     'redim final arrays with this value
  78.     ReDim aryItems(iItems)
  79.     ReDim aryItemsLoc(iItems)
  80.     ReDim aryDesc(iItems)
  81.  
  82.    
  83.     'copy from temp array to the final ones
  84.     i=1
  85.     for l=1 to e-1
  86.         If Len(aryTemp(l))>0 then
  87.            aryItems(i)=aryTemp(l)
  88.            aryItemsLoc(i)=aryTemp2(l)
  89.            i=i+1
  90.         end if
  91.     next
  92.  
  93.     'fill third array with the file description
  94.     for l=1 to iItems
  95.         aryDesc(l)=GetFileDescription(aryItems(l))
  96.     next 
  97.  
  98.     'AND NOW update the UI
  99.     for l=1 to iItems
  100.         Call SetUIElement(l,aryDesc(l) & " (" & aryItems(l) & ")") 'set data in X-Setup
  101.         if Right(aryItemsLoc(l),1)<>"-" then 'not disabled
  102.            Call SetUIElementEx(l,true) 'set activated
  103.         else
  104.            Call SetUIElementEx(l,false) 'set not active
  105.         end if
  106.     Next
  107. End Sub
  108.  
  109.  
  110. 'VERSION 1.1
  111. 'returns the readable description for a file TYPE. Input is the
  112. 'raw file type (e.g. ".TXT"). 
  113. Function GetFileDescription(DotType)
  114.   sxd_BasePath="HKLM\Software\Classes\"
  115.  
  116.   sxd_Path=sxd_BasePath & DotType & "\@"
  117.   sxd_Val=RegReadValue(sxd_Path)
  118.  
  119.   if IsEmpty(sxd_Val)=true then
  120.      'extended description not found! return default
  121.      GetFileDescription="<UNKNOWN>"
  122.   else
  123.      'found, now get the "real" description
  124.      sxd_Path=sxd_BasePath & sxd_Val & "\@"
  125.      sxd_Name=RegReadValue(sxd_Path)
  126.      
  127.      if IsEmpty(sxd_Name)=true then
  128.         'argh! 
  129.         GetFileDescription="<UNKNOWN>"
  130.      else
  131.         GetFileDescription=sxd_Name
  132.      end if
  133.   end if
  134.  
  135. End Function
  136.  
  137.  
  138. 'VERSION 1.0
  139. 'returns the reg path to the InfoTip value path or "" if nothing was found. Input is the
  140. 'path to the data type (e.g. "HKCR\.TXT"). 
  141. Function HasOpenWarning(StartPath,Path)
  142.  Dim sCheck,sReturn
  143.  xd_sV_NoOpen="\NoOpen"
  144.  sReturn=""
  145.  
  146.  'first check if this file has a name. If so
  147.  'read the data from that name
  148.  s=RegReadValue(Path & "\@")
  149.  if IsEmpty(s)=false then          
  150.     '<default path>\.XXX File\NoOpen
  151.     sCheck=StartPath & s & xd_sV_NoOpen
  152.     if RegValueExists(sCheck) then
  153.        sReturn=sCheck
  154.     end if
  155.  else
  156.     'okay, seems this file has no name
  157.     sCheck=Path & xd_sV_NoOpen
  158.     if RegValueExists(sCheck) then
  159.        sReturn=sCheck
  160.     end if
  161.  end if
  162.  
  163.  HasOpenWarning=sReturn
  164. End Function
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171. Sub Plugin_Apply(ElementIndex,ElementSubIndex)
  172.  if ElementSubIndex>0 then
  173.  
  174.     if ElementIndex=1 then 'change
  175.        sCurPath=aryItemsLoc(ElementSubIndex)
  176.        s=RegReadValue(sCurPath)         
  177.        s=InputWindow("Please enter the warning that should appear e.g. <Ask the sysop!> or leave empty to display the Windows default warning",s,1) 
  178.        if IsEmpty(s)=false then
  179.           Call RegWriteValue(sCurPath,s,1)
  180.        end if
  181.     end if
  182.  
  183.     if ElementIndex=2 then 'delete
  184.        sCurPath=aryItemsLoc(ElementSubIndex)
  185.        Call RegDeleteValue(sCurPath)
  186.     end if
  187.      
  188.  
  189.     'call the holy Windows API
  190.     Call IndicateSettingChange()
  191.  
  192.     're-read UI
  193.     Call ReadRegistry
  194.  else
  195.     Call MsgWarning("Please select an item in the list.")
  196.  end if
  197.  
  198. End Sub
  199.  
  200.  
  201.  
  202. Sub Plugin_Terminate 
  203. End Sub
  204.